// 简单的API测试脚本
const axios = require('axios');

const BASE_URL = 'http://localhost:3000';

async function testHealthCheck() {
  try {
    console.log('🔍 测试健康检查接口...');
    const response = await axios.get(`${BASE_URL}/health`);
    console.log('✅ 健康检查成功:', response.data);
  } catch (error) {
    console.error('❌ 健康检查失败:', error.message);
  }
}

async function testDeepSeekStatus() {
  try {
    console.log('🔍 测试DeepSeek状态接口...');
    const response = await axios.get(`${BASE_URL}/api/deepseek/status`);
    console.log('✅ DeepSeek状态检查成功:', response.data);
  } catch (error) {
    console.error('❌ DeepSeek状态检查失败:', error.message);
  }
}

async function testDeepSeekChat() {
  try {
    console.log('🔍 测试DeepSeek聊天接口...');
    const response = await axios.post(`${BASE_URL}/api/deepseek/chat`, {
      content: '你好，请简单介绍一下你自己'
    });
    console.log('✅ DeepSeek聊天测试成功:', response.data);
  } catch (error) {
    console.error('❌ DeepSeek聊天测试失败:', error.response?.data || error.message);
  }
}

async function runTests() {
  console.log('🚀 开始API测试...\n');
  
  await testHealthCheck();
  console.log('');
  
  await testDeepSeekStatus();
  console.log('');
  
  await testDeepSeekChat();
  console.log('');
  
  console.log('✨ 测试完成！');
}

// 延迟执行，给服务器启动时间
setTimeout(runTests, 2000); 